//
//  CilckTitleView.swift
//  SwiftDemo
//
//  Created by admin on 2020/10/15.
//

import UIKit

class CilckTitleView: UIButton {
    override init(frame: CGRect) {
        super.init(frame: frame)
        setTitle("coderWhy", for: .normal)
        setTitleColor(UIColor.red, for: .normal)
        setImage(UIImage(named: "qp-sy"), for: .normal)
        setImage(UIImage(named: "qp-sy-sel"), for: .selected)
        sizeToFit()
    }

//重写了  init(frame: CGRect)方法 必须重写 下面方法（init?(coder: NSCoder)）
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")

    }

    override func layoutSubviews() {
        super.layoutSubviews()

        titleLabel?.frame.origin.x = 0
        imageView?.frame.origin.x = (titleLabel?.frame.size.width)! + 5

    }

}
